using System.Collections.Generic;

namespace SeguradoraIA.Framework.Business
{
    public class AggregationManager<T> where T:class 
    {
        private static readonly List<IAggregationRule<T>> dependencies = new List<IAggregationRule<T>>();

        public void AddAggregationRule(IAggregationRule<T> aggregation)
        {
            dependencies.Add(aggregation);
        }

        public void Delete(params object[] keyParameters)
        {
            dependencies.ForEach(d => d.DeleteRule(keyParameters));
        }

        public void Update(T to)
        {
            dependencies.ForEach(d => d.UpdateRule(to));
        }

        public void Get(IList<T> lista)
        {
            foreach (var to in lista)
            {
                Get(to);
            }
        }

        public void Get(T to)
        {
            if (to != null)
            {
                dependencies.ForEach(d => d.GetRule(to));
            }
        }

        public void Insert(T to)
        {
            dependencies.ForEach(d => d.InsertRule(to));
        }
    }
}